home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’97
/
Whack-A-Bill
/
source code
/
score.h
< prev
next >
Wrap
Text File
|
1997-09-24
|
4KB
|
213 lines
void updateScores(long PlayerOneScore,long PlayerTwoScore);
void SetupScores(void);
void DrawCurrent(int theNumber, Rect theRect);
Boolean scoresSetup=false;
PicHandle zero,
one,
two,
three,
four,
five,
six,
seven,
eight,
nine;
typedef struct score
{
Rect One,
Ten,
Hundred,
Thousand,
TenThousand,
HundredThousand;
}score;
score PlayerOneScoreStruct,
PlayerTwoScoreStruct;
void updateScores(long PlayerOneScore,long PlayerTwoScore)
{
WindowPtr oldPort;
int count;
long scoreBuffer;
if (!(scoresSetup))
SetupScores();
GetPort(&oldPort);
SetPort(gMainWindow);
//---------------PlayerOne--------------
scoreBuffer=PlayerOneScore;
count=0;
while (scoreBuffer>99999)
{
count++;
scoreBuffer=(scoreBuffer-100000);
}
DrawCurrent(count,PlayerOneScoreStruct.HundredThousand);
count=0;
while (scoreBuffer>9999)
{
count++;
scoreBuffer=(scoreBuffer-10000);
}
DrawCurrent(count,PlayerOneScoreStruct.TenThousand);
count=0;
while (scoreBuffer>999)
{
count++;
scoreBuffer=(scoreBuffer-1000);
}
DrawCurrent(count,PlayerOneScoreStruct.Thousand);
count=0;
while (scoreBuffer>99)
{
count++;
scoreBuffer=(scoreBuffer-100);
}
DrawCurrent(count,PlayerOneScoreStruct.Hundred);
count=0;
while (scoreBuffer>9)
{
count++;
scoreBuffer=(scoreBuffer-10);
}
DrawCurrent(count,PlayerOneScoreStruct.Ten);
count=0;
while (scoreBuffer>0)
{
count++;
scoreBuffer=(scoreBuffer-1);
}
DrawCurrent(count,PlayerOneScoreStruct.One);
//---------------PlayerTwo--------------
scoreBuffer=PlayerTwoScore;
count=0;
while (scoreBuffer>99999)
{
count++;
scoreBuffer=(scoreBuffer-100000);
}
DrawCurrent(count,PlayerTwoScoreStruct.HundredThousand);
count=0;
while (scoreBuffer>9999)
{
count++;
scoreBuffer=(scoreBuffer-10000);
}
DrawCurrent(count,PlayerTwoScoreStruct.TenThousand);
count=0;
while (scoreBuffer>999)
{
count++;
scoreBuffer=(scoreBuffer-1000);
}
DrawCurrent(count,PlayerTwoScoreStruct.Thousand);
count=0;
while (scoreBuffer>99)
{
count++;
scoreBuffer=(scoreBuffer-100);
}
DrawCurrent(count,PlayerTwoScoreStruct.Hundred);
count=0;
while (scoreBuffer>9)
{
count++;
scoreBuffer=(scoreBuffer-10);
}
DrawCurrent(count,PlayerTwoScoreStruct.Ten);
count=0;
while (scoreBuffer>0)
{
count++;
scoreBuffer=(scoreBuffer-1);
}
DrawCurrent(count,PlayerTwoScoreStruct.One);
SetPort(oldPort);
}
void DrawCurrent(int theNumber, Rect theRect)
{
switch (theNumber)
{
case 0:
DrawPicture(zero,&theRect);
break;
case 1:
DrawPicture(one,&theRect);
break;
case 2:
DrawPicture(two,&theRect);
break;
case 3:
DrawPicture(three,&theRect);
break;
case 4:
DrawPicture(four,&theRect);
break;
case 5:
DrawPicture(five,&theRect);
break;
case 6:
DrawPicture(six,&theRect);
break;
case 7:
DrawPicture(seven,&theRect);
break;
case 8:
DrawPicture(eight,&theRect);
break;
case 9:
DrawPicture(nine,&theRect);
break;
}
}
void SetupScores(void)
{
PicHandle One,
Ten,
Hundred,
Thousand,
TenThousand,
HundredThousand;
SetRect(&PlayerOneScoreStruct.HundredThousand,540,177,553,202);
SetRect(&PlayerOneScoreStruct.TenThousand,553,177,566,202);
SetRect(&PlayerOneScoreStruct.Thousand,566,177,579,202);
SetRect(&PlayerOneScoreStruct.Hundred,579,177,592,202);
SetRect(&PlayerOneScoreStruct.Ten,592,177,605,202);
SetRect(&PlayerOneScoreStruct.One,605,177,618,202);
SetRect(&PlayerTwoScoreStruct.HundredThousand,540,311,553,336);
SetRect(&PlayerTwoScoreStruct.TenThousand,553,311,566,336);
SetRect(&PlayerTwoScoreStruct.Thousand,566,311,579,336);
SetRect(&PlayerTwoScoreStruct.Hundred,579,311,592,336);
SetRect(&PlayerTwoScoreStruct.Ten,592,311,605,336);
SetRect(&PlayerTwoScoreStruct.One,605,311,618,336);
if (playerOne.score==5)
SysBeep(1);
zero=GetPicture(1200);
one=GetPicture(1201);
two=GetPicture(1202);
three=GetPicture(1203);
four=GetPicture(1204);
five=GetPicture(1205);
six=GetPicture(1206);
seven=GetPicture(1207);
eight=GetPicture(1208);
nine=GetPicture(1209);
scoresSetup=true;
}